/**
 * 
 */
/*
window.onload=function()
{
	arr = new Array();
}
*/
function Score(mid, kor, eng)
{
	this.mid=mid;
	this.kor=kor;
	this.eng=eng;
	this.tot=0;
	this.avg=0;
	this.compute = function()
	{
		this.tot = Number(this.kor) + Number(this.eng);
		this.avg = this.tot/2;
	}
	/*tot와 avg에 해당하는 getter생성*/
	this.getTot=function(){return this.tot;}
	this.getAvg=function(){return this.avg;}
	this.getMid=function(){return this.mid;}
	this.getKor=function(){return this.kor;}
	this.getEng=function(){return this.eng;}
}
function objectTestinit()
{
	arr = new Array();
	var f = document.frm3;
	/*
	var m = document.getElementsByName('mid');
	alert(m.value);
	*/
	
	
	document.getElementById('btngo').onclick=function()
	{
		var s1 = new Score(f.mid.value, f.kor.value, f.eng.value);
		s1.compute();
		f.tot.value = s1.getTot();
		f.avg.value = s1.getAvg();
		arr.push(s1);
	}
	document.getElementById('btnlist').onclick=function()
	{
		var st;
		st = '<center>'+'<table border="1">';
		st += '<tr>'+'<td>'+"아이디"+'</td>'+'<td>'+"국어"+'</td>'+'<td>'+"영어"+'</td>'+'<td>'+"총점"+'</td>'+'<td>'+"평균"+'</td>'+'</tr>';
		for(a=0;a<arr.length;a++)
		{
			st += '<tr>'+'<td>'+arr[a].getMid()+'</td>'+'<td>'+arr[a].getKor()+'</td>'+'<td>'+arr[a].getEng()+'</td>'+'<td>'+arr[a].getTot()+'</td>'+'<td>'+arr[a].getAvg()+'</td>'+'</tr>';
			//document.getElementById('resultDiv').innerHTML += arr[a].ar;
			//document.getElementById('resultDiv').innerHTML = '<table border="1">'+'<tr>'+'<td>'+"으아"+'</td>'+'<td>'+"아으"+'</td>'+'</tr>'+'</table>';
		}
		st += '</table>'+'</center>';
		document.getElementById('resultDiv').innerHTML = st;
	}
	document.getElementById('btnclear').onclick=function()
	{
		f.mid.value = '';
		f.kor.value = '';
		f.eng.value = '';
		f.tot.value = '';
		f.avg.value = '';
	}
	document.getElementById('btncho').onclick=function()
	{
		f.mid.value = '';
		f.kor.value = '';
		f.eng.value = '';
		f.tot.value = '';
		f.avg.value = '';
		document.getElementById('resultDiv').innerHTML = '';
		arr = new Array();
	}
}